package cn.fengwoo.springBoot.utils;

import cn.fengwoo.springBoot.entity.Result;
import cn.fengwoo.springBoot.enums.ResultEnum;

/**
 * Created by 廖师兄
 * 2017-01-21 13:39
 */
public class ResultUtil {

    public static Result success(ResultEnum resultEnum, Object object) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMessage(resultEnum.getMsg());
        result.setData(object);
        result.setSuccess(Boolean.TRUE);
        return result;
    }

    public static Result success(ResultEnum resultEnum) {
        return success(resultEnum,null);
    }

    public static Result error(ResultEnum resultEnum, Object object) {
        Result result = new Result();
        result.setCode(resultEnum.getCode());
        result.setMessage(resultEnum.getMsg());
        result.setData(object);
        result.setSuccess(Boolean.FALSE);
        return result;
    }

    public static Result error(ResultEnum resultEnum) {
        return error(resultEnum,null);
    }
}
